home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Online / LineShare 3.3.1 / LineShare Scripts / Supra Voice&Fax1&ARA < prev    next >
Text File  |  1994-09-08  |  10KB  |  585 lines

  1. !V2.2.10
  2. !
  3. !$ Use this script with Supra 14400bps and 9600bps fax modems.
  4. !$ Supports: voice, fax, and ARA incoming calls.
  5. !
  6. !$ Make sure that *Class 1* fax software is installed, and that
  7. !$ your modem has voice-capable ROMs.
  8. !
  9. !$ A hardware handshaking cable is required.
  10.  
  11. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1","Always"="2") "1"
  12. ^3 Speaker Volume:   = Enum("Low"="1","Medium"="2","High"="3") "2"
  13. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^6 Handshake wires:   = Bool("Both"="&D0\K0","CTS only"="&D2\K5") "&D2\K5"
  15. ! ------------------------------------------
  16. ! Resetting the modem:
  17. ! ------------------------------------------
  18. @HANGUP
  19.   SerReset 19200,0,8,1
  20.   HsReset 0,0,17,19,0,0
  21.   Flush
  22.   SetTries 2
  23.   write "ATH0S0=0\r"
  24.   Flush
  25.  
  26. !
  27. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  28. ! to enter the command mode
  29. !
  30. @Label 1
  31.   write "AT+VC=0\r"
  32.   flush
  33.   write "AT&F1\r"
  34.   matchclr
  35.   matchstr 1 2 "OK\r\n"
  36.   matchread 20
  37. !  chrdelay 1
  38.   Write "+++"
  39. !  chrdelay 0
  40.   DtrClear
  41.   LBreak
  42.   DtrSet
  43.  
  44.   write "AT+VC=0\r"
  45.   matchclr
  46.   matchstr 1 1 "OK\r\n"
  47.   matchread 10
  48. !
  49.   write "ATE0V1\r"
  50.   matchstr 1 1 "OK\r\n"
  51.   matchread 10
  52.  
  53.   write "ATH0\r"
  54.   matchstr 1 1 "OK\r\n"
  55.   matchread 10
  56.   DecTries
  57.   IfTries 0 1
  58.   exit -6019
  59.  
  60. @Label 2
  61.   SerReset 19200,0,8,1
  62.   Jsr 80
  63.   Write "AT+FCLASS=0\r"
  64.   Jsr 100
  65.   Write "AT+FAE=0\r"
  66.   Jsr 100
  67.   exit 0
  68.  
  69.  
  70. ! ------------------------------------------
  71. !    Receiving incoming calls
  72. ! ------------------------------------------
  73. @ANSWER
  74. !
  75. ! Set the modem preferred speed first
  76. !
  77.    SerReset 19200,0,8,1
  78.   Jsr 80
  79.   Jsr 70
  80.  
  81. @Label 3
  82.   ifOpen "Voice" 4
  83.   Jump 47
  84.  
  85. ! check to see if the voice code has been downloaded
  86. ! if not, tell PhonePro to download it.
  87. !
  88. @Label 4
  89.   Note "Checking the modem..."
  90.   Write "AT+VC=0\r"
  91.   MatchClr
  92.   MatchStr 1 5 "OK\r\n"
  93.   MatchStr 2 5 "ERROR\r\n"
  94.   MatchRead 10
  95.   Exit -6019
  96.  
  97. @Label 5
  98.   Write "AT+VC=1\r"
  99.   MatchClr
  100.   MatchStr 1 7 "OK\r\n"
  101.   MatchStr 2 6 "ERROR\r\n"
  102.   MatchRead 20
  103.   Exit -6019
  104. !
  105. !  tell the Voice Tool to download the voice code
  106. !
  107. @Label 6
  108.   Note "Downloading voice code to modem..."
  109.   Pause 20
  110.   QueueInput "\r\nLOAD\r\n"
  111.   Attach "Voice" (Master)
  112.  
  113. @Label 7
  114.   Write "AT+VC=0\r"
  115.   Jsr 100
  116.  
  117. !
  118. ! sit and wait for a call for up to 30 seconds, then re-initiate the modem
  119. !
  120. !@Label 8
  121. !
  122. ! Get caller ID, if voice enabled
  123.   QueueInput "\r\nGET_CALLER_ID_FLAG\r\n"
  124.   Attach "Voice" (Master)
  125.   SetVar B "^$"
  126.   Write "AT#CID=^B\r"
  127.   Jsr 100
  128.  
  129.   Note "Waiting for a Voice/Fax/ARA call"
  130.   MatchClr
  131.   MatchStr 1 15 "RING\r\n"
  132.   MatchRead 1800
  133.   Jump 3
  134.  
  135. @Label 15
  136.   Note "Ring..."
  137.   QueueInput "\r\nRING\r\n"
  138.   Attach "Voice" (Master)
  139.   Write "+++"
  140.   Note "Switching from voice..."
  141.  
  142. ! fall through if the call is not a voice call (as indicated by the telephone tool)
  143. !
  144.   SetVar A "^$"
  145.   SerReset 19200,0,8,1
  146. !  Jsr 80
  147.   HsReset 0,0,17,19,0,0
  148. !  Write "\r\r\r"
  149. !  Pause 10
  150.   Jsr 80
  151.  
  152. !  Write "ATV1E0\r"
  153. !  Jsr 100
  154.  
  155. !  Pause 2
  156. !  Write "AT&F\r"
  157. !  Jsr 100
  158.  
  159. !  Jsr 70
  160.  
  161.   IfStr A 17 "Fax"
  162.   IfStr A 18 "ARA"
  163.   Exit -6019
  164.  
  165. !
  166. ! Force to answer a Fax call
  167. !
  168. @Label 17
  169.   Note "Switching to Fax..."
  170.   Write "AT+FCLASS=1;+FAE=0\r"
  171.   Jsr 100
  172.   Write "AT&K4E0V0A\r"
  173.   MatchClr
  174.   MatchStr 1 30 "1\r"
  175.   MatchStr 2 93 "3\r"
  176.   MatchStr 3 94 "8\r"
  177.   MatchRead 300
  178.   Write "\r"
  179.   Exit -6019
  180.  
  181. !
  182. ! Force to answer an ARA call
  183. !
  184. @Label 18
  185.   Note "Switching to ARA..."
  186.   Jsr 70
  187. ! Set the communication options:
  188.   Jsr 55
  189.  
  190.   Write "AT+FAE=0;+FCLASS=0\r"
  191.   Jsr 100
  192.   Write "ATA\r"
  193.   MatchClr
  194.   MatchStr 1 20 "\r\nCARRIER "
  195.   MatchStr 4 93 "NO CARRIER\r\n"
  196.   MatchStr 5 94 "NO ANSWER\r\n"
  197.   MatchRead 300
  198.   Write "\r"
  199.   Exit -6019
  200.  
  201. @Label 20
  202.   QueueInput "\r\nCARRIER "
  203.   ifOriginate 21
  204.   QueueInput "\r\nRING\r\n"
  205. @Label 21
  206.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  207.  
  208. !
  209. ! Fax connection has been established (we read "1\r")
  210. ! Attach the "Fax" subPort
  211. !
  212. @Label 30
  213.  
  214.   QueueInput "1\r"
  215.   ifOriginate 32
  216. @Label 31
  217.   QueueInput "2\r"
  218. @Label 32
  219.   Attach "Fax" (DTR,Reset)
  220.  
  221. !
  222. ! Converting numeric responses into verbal
  223. !
  224. @Label 40
  225.   QueueInput "2400\r\n"
  226.   Jump 20
  227. @Label 41
  228.   QueueInput "4800\r\n"
  229.   Jump 20
  230. @Label 42
  231.   QueueInput "7200\r\n"
  232.   Jump 20
  233. @Label 43
  234.   QueueInput "9600\r\n"
  235.   Jump 20
  236. @Label 44
  237.   QueueInput "12000\r\n"
  238.   Jump 20
  239. @Label 45
  240.   QueueInput "14400\r\n"
  241.   Jump 20
  242.  
  243. !
  244. ! Waiting for Fax/ARA calls only (no Voice App running)
  245. !
  246. @Label 47
  247.   Note "Voice Application is not running..."
  248.   Jsr 55
  249.  
  250. !  No Voice App running -- turn off caller ID
  251.   Write "AT#CID=0\r"
  252.   Jsr 100
  253.  
  254. !  This would allow us to not go into AA mode if we could have more labels.
  255.   ifOpen "ARA" 49
  256.   ifOpen "Fax" 49
  257.   Jump 160
  258. !
  259. !
  260. ! Set Fax mode
  261. !
  262. @Label 49
  263.   Write "AT\\N0&Q6&K3W1\r"
  264.   Jsr 100
  265.   Write "AT+FCLASS=1\r"
  266.   Jsr 100
  267.   Write "AT+FAE=1\r"
  268.   Jsr 100
  269.   Write "AT+FCLASS=0\r"
  270.   Jsr 100
  271. !
  272. ! Tell the modem to determine the type of the incoming call
  273. ! Fetch the tube after ^4 rings
  274. !
  275.  Write "ATS0=^4V0\r"
  276.   Jsr 110
  277. !
  278. ! Everything is ready - let's sit and wait for a call
  279. ! We'll wait for 30 seconds, then reinitiate the modem
  280. !
  281.   Note "Waiting for a fax or ARA call..."
  282.   MatchClr
  283.   matchstr 02 40 "47\r"
  284.   MatchStr 03 41 "48\r"
  285.   MatchStr 04 42 "49\r"
  286.   MatchStr 05 43 "50\r"
  287.   MatchStr 06 44 "51\r"
  288.   MatchStr 07 45 "52\r"
  289.   MatchStr 09 31 "33\r"
  290.   matchstr 10 53 "2\r"
  291.   matchstr 12 30 "1\r"
  292.   matchstr 13 52 "3\r"
  293.   matchstr 14 52 "8\r"
  294.   matchstr 15 52 "7\r"
  295. @Label 51
  296.   Matchread 600
  297. @Label 52
  298.   Write "ATV1\r"
  299.   Jsr 100
  300.   Jump 3
  301. @Label 53
  302.   Note "Ring..."
  303.   Jump 51
  304.  
  305. ! ------------------------------------------
  306. ! Originating a call through the "Voice" subport
  307. ! ------------------------------------------
  308. @ORIGINATE "Voice" ("\r\nBusy\r\n")
  309.   Note "PhonePro is originating a call ..."
  310.   SerReset *
  311.   HsReset *
  312.   Jsr 80
  313. ! Jsr 60
  314.   Write "ATD^1\r"
  315.   Attach "Voice" (Escape,IdleLimit=30,Reset,DTR)
  316.   Exit -6019
  317.  
  318.  
  319.  
  320. ! ------------------------------------------
  321. ! Originating a call through the "ARA" subport
  322. ! ------------------------------------------
  323. @ORIGINATE "ARA" ("\r\nBusy\r\n")
  324.   SerReset *
  325.   HsReset *
  326.   Jsr 80
  327. !
  328. ! Set the common options
  329. !
  330.   Jsr 70
  331.   Jsr 55
  332. !
  333. ! Prepare to receive all error result codes, dial the number
  334. !
  335.   Jsr 90
  336.   MatchStr 1 20 "\r\nCARRIER "
  337.   MatchRead 1000
  338.   Write "\r"
  339.   Exit -6019
  340.  
  341. ! ------------------------------------------
  342. ! Originating a call through the "Fax" subPort
  343. ! ------------------------------------------
  344. @ORIGINATE "Fax" ("\r\nBUSY\r\n")
  345. ! Clear the modem's magic memory
  346.   Jsr 130
  347. !
  348. ! Set the "Fax" speed
  349. !
  350.   SerReset *
  351.   HsReset *
  352.   Jsr 80
  353.   Write "ATZ\r"
  354.   Jsr 100
  355.  
  356.   Write "AT+VC=0\r"
  357.   Jsr 120
  358.  
  359.  
  360. !
  361. ! Set the common options
  362. !
  363.   Jsr 70
  364. !
  365. ! Set the Fax mode
  366. ! &K4: Xon/Xoff handshake
  367. !
  368.   Write "AT&K4+FCLASS=1\r"
  369.   Jsr 100
  370.   Write "AT+VC=0\r"
  371.   Jsr 120
  372. !
  373. ! Now emit all commands that the application has sent to that port,
  374. ! except "+FCLASS", etc
  375. !
  376.   EmitClear "+FCLASS","V","E","S0"
  377.   Jsr 60
  378.   Write "ATV0\r"
  379.   Jsr 110
  380. !
  381. ! Prepare to receive all error result codes, dial the number
  382. !
  383.   MatchClr
  384.   MatchStr 01 30 "1\r"
  385.   MatchStr 13 93 "3\r"
  386.   MatchStr 14 94 "8\r"
  387.   MatchStr 15 92 "7\r"
  388.   Write "ATD^1\r"
  389.   HsReset *
  390.   MatchRead 900
  391.   Write "\r"
  392.   Exit -6019
  393.  
  394. !
  395. ! Set the communication options:
  396. ! • \N0 &Q6: Normal connection (for ARA)
  397. ! • &K3: HW flow control       (for ARA, Fax should not use a handshake on receiving)
  398. ! • W1:  report connection speed
  399. !
  400. @Label 55
  401.   Write "AT\\N0&Q6&K3W1\r"
  402.   Jsr 100
  403.   return
  404.  
  405. !
  406. ! This section emits all modem commands sent from the client application
  407. ! For each set of commands the "OK" answer is awaited
  408. !
  409. @Label 60
  410.   EmitStart
  411. @Label 61
  412.   EmitCommand 62
  413.   Jsr 100
  414.   Jump 61
  415. @Label 62
  416.   return
  417. !
  418. ! This section initiates the modem before ANSWER and ORIGINATEs:
  419. ! extended responses + connect at the highest rate + speaker control +
  420. ! reset on Dtr drop + DCD valid
  421. ! Verbal responses mode, no echo
  422. !
  423. @Label 70
  424.   Write "ATX4N1M^2L^3^6&C1V1E0\r"
  425.   Jsr 100
  426.   return
  427.  
  428. !
  429. ! This section syncronize the modem after the serial port speed switching
  430. !
  431. @Label 80
  432.   ChrDelay 1
  433.   Write "\r\r"
  434.   Pause 2
  435.   Write "AT\r"
  436.   ChrDelay 0
  437.   Jsr 100
  438.   return
  439. !
  440. ! Prepare to receive error result codes, send the dialing command and
  441. ! set the user's handshake mode
  442. !
  443. @Label 90
  444.   MatchClr
  445.   MatchStr 2 91 "NO DIALTONE\r\n"
  446.   MatchStr 3 92 "BUSY\r\n"
  447.   MatchStr 4 93 "NO CARRIER\r\n"
  448.   MatchStr 5 94 "NO ANSWER\r\n"
  449.   Write "ATD^1\r"
  450.   HsReset *
  451.   return
  452.  
  453. @Label 91
  454.   exit -6020
  455. @Label 92
  456.   exit -6022
  457. @Label 93
  458.   exit -6021
  459. @Label 94
  460.   exit -6023
  461. !
  462. ! Processing the AT command:
  463. ! OK -> proceed
  464. ! ERROR or TimeOut ->exit -6019
  465. ! It can be called AFTER the "Write" command, since LineShare buffers input
  466. !
  467. @Label 100
  468.   MatchClr
  469.   MatchStr 1 103 "\r\nOK\r\n"
  470.   MatchStr 2 102 "\r\nERROR\r\n"
  471. @Label 101
  472.   MatchRead 20
  473. @Label 102
  474.   Exit -6019
  475. @Label 103
  476.   return
  477.  
  478. @Label 110
  479.   MatchClr
  480.   MatchStr 1 103 "0\r"
  481.   MatchStr 2 102 "4\r"
  482.   Jump 101
  483.  
  484. @Label 120
  485.   MatchClr
  486.   MatchStr 1 103 "\r\nOK\r\n"
  487.   MatchStr 2 103 "\r\nERROR\r\n"
  488.   MatchRead 20
  489.   Exit -6019
  490.  
  491. !This zeros out a location in memory that
  492. !when cleared, enables STF to send/receive faxes.
  493. @Label 130
  494.   MatchClr
  495.   Write "AT!2000M\r"
  496.   MatchStr 1 131 "\r\n2000: "
  497.   MatchRead 20
  498.   Jump 150
  499.  
  500. @Label 131
  501.   MatchClr
  502.   Write "00"
  503.   MatchStr 1 132 "\r\n2001: "
  504.   MatchRead20
  505.   Jump 150
  506.  
  507. @Label 132
  508.   MatchClr
  509.   Write "00"
  510.   MatchStr 1 133 "\r\n2002: "
  511.   MatchRead 20
  512.   Jump 150
  513.  
  514. @Label 133
  515.   MatchClr
  516.   Write "00"
  517.   MatchStr 1 134 "\r\n2003: "
  518.   MatchRead 20
  519.   Jump 150
  520.  
  521. @Label 134
  522.   MatchClr
  523.   Write "00"
  524.   MatchStr 1 135 "\r\n2004: "
  525.   MatchRead 20
  526.   Jump 150
  527.  
  528. @Label 135
  529.   MatchClr
  530.   Write " "
  531.   Jsr 100
  532.  
  533. @Label 136
  534.   MatchClr
  535.   Write "AT!2007M\r"
  536.   MatchStr 1 137 "\r\n2007: "
  537.   MatchRead 20
  538.   Jump 150
  539.  
  540. @Label 137
  541.   MatchClr
  542.   Write "00"
  543.   MatchStr 1 138 "\r\n2008: "
  544.   MatchRead20
  545.   Jump 150
  546.  
  547. @Label 138
  548.   MatchClr
  549.   Write "00"
  550.   MatchStr 1 139 "\r\n2009: "
  551.   MatchRead20
  552.   Jump 150
  553.  
  554. @Label 139
  555.   MatchClr
  556.   Write "00"
  557.   MatchStr 1 140 "\r\n200A: "
  558.   MatchRead20
  559.   Jump 150
  560.  
  561. @Label 140
  562.   MatchClr
  563.   Write "00"
  564.   MatchStr 1 141 "\r\n200B: "
  565.   MatchRead20
  566.   Jump 150
  567.  
  568. @Label 141
  569.   Write " "
  570.   Jsr 100
  571.   return
  572.  
  573. @Label 150
  574.   Note "Error clearing the modem's memory"
  575.   Pause 50
  576.   Write "   "
  577.   return
  578.  
  579. @Label 160
  580.   write "ATS0=0\r"
  581.   Jsr 100
  582.   Note "Voice, ARA, and Fax not running"
  583.   Pause 300
  584.   Jump 3
  585.